﻿//创建时间: 2010-11-12
//创建作者: 李晓忠
//功能说明: CMS系统 内容链接状态查看 
//修改: 2010-11-12 
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using Newtonsoft.Json;

namespace TRPOP.CMS.Web.Admin
{
    public partial class content_viewLinkState : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.Content_AllControl;
        }
        #endregion


        #region 页面变量
        int m_intNodeId = 0;
        int m_intContentId = 0;
        protected string strCurrentLinkType = "";
        protected string strLink1 = "";
        protected string strLink0 = "";
        protected string strLink2 = "";
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            m_intContentId = RequestHelper.RequestInt("contentid");
            m_intNodeId = RequestHelper.RequestInt("nodeid");
           
            if (!IsPostBack)
            {
                LoadBase();
                BindData();
            }
        }
        #endregion

        #region 页面方法

        public void LoadBase()
        {
           
        }

        public void BindData()
        {
            if (m_intContentId > 0)
            {
                ContentManage m_ContentManage=new ContentManage();
                NodeManage m_NodeManage = new NodeManage();
                int m_intExtendId = 0;
                #region 当前链接
                ContentInfo m_ContentInfo = m_ContentManage.GetInfoById(m_intContentId);
                if (m_ContentInfo != null)
                {
                    m_intExtendId = m_ContentInfo.ExtendId;
                    if (m_ContentInfo.Type == 0)
                    {
                        strCurrentLinkType = "虚链接";
                    }
                    else if (m_ContentInfo.Type == 1)
                    {
                        strCurrentLinkType = "实链接";
                    }
                    else if (m_ContentInfo.Type == 2)
                    {
                        strCurrentLinkType = " 索引链接";
                    }
                    strCurrentLinkType += "[<a href=\""+m_ContentInfo.Url+"\"  target=\"_blank\">查看</a>]";
                }
                #endregion

                List<ContentInfo> m_ContentInfoList = new List<ContentInfo>();
                #region 实链接
                m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND ExtendId=" + m_intExtendId + "  AND [Type]=" + (int)LinkType.EnumElement.RealLink, " ContentId asc");
                foreach (ContentInfo info in m_ContentInfoList)
                {
                    if (info.PubStatus!=(int)PubStatus.EnumElement.Delete)
                    strLink1 += "<b>"+m_NodeManage.GetNodeNameById(info.NodeId)+"</b> [<a href=\"javascript:doing('edit','"+info.ContentId+"','"+info.NodeId+"');\">编辑</a>]";
                }
                #endregion

                #region 虚链接
                m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND ExtendId=" + m_intExtendId + "   AND [Type]="+ (int)LinkType.EnumElement.VirtualLink, " ContentId asc");
                foreach (ContentInfo info in m_ContentInfoList)
                {
                    if (info.PubStatus != (int)PubStatus.EnumElement.Delete)
                    strLink0 += "<b>" + m_NodeManage.GetNodeNameById(info.NodeId) + "</b> [<a href=\"javascript:doing('del','" + info.ContentId + "','" + info.NodeId + "');\">删除</a>]<br/>";
                }
                #endregion

                #region 索引链接
                m_ContentInfoList = m_ContentManage.GetListByCondition(0, " AND ExtendId=" + m_intExtendId + "  AND [Type]=" +(int)LinkType.EnumElement.IndexLink, " ContentId asc");
                foreach (ContentInfo info in m_ContentInfoList)
                {
                    if (info.PubStatus != (int)PubStatus.EnumElement.Delete)
                    strLink2 += "<b>" + m_NodeManage.GetNodeNameById(info.NodeId) + "</b> [<a href=\"javascript:doing('del','" + info.ContentId + "','" + info.NodeId + "');\">删除</a>]<br/>";
                }
                #endregion
            }

        }


        #endregion
    }
}
